package org.nepu.scr.indexrate.converter.drillingrate.keydevice.nozzlesystem;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.drillingrate.keydevice.nozzlesystem.NozzleDevice;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class NozzleDeviceConverter implements AttributeConverter<NozzleDevice, String> {
    @Override
    public String convertToDatabaseColumn(NozzleDevice nozzleDevice) {
        return JSONUtil.toJsonStr(nozzleDevice);
    }

    @Override
    public NozzleDevice convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, NozzleDevice.class);
    }
}
